package cn.yeziji.forum.controller;

import cn.yeziji.forum.common.ForumResult;
import cn.yeziji.forum.dao.intf.ForumCommentDao;
import cn.yeziji.forum.dto.comment.ForumDetailCommentDTO;
import cn.yeziji.forum.utils.ForumResultUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 评论控制器
 *
 * @author gzkemays
 * @since 2022/1/11 20:56
 */
@RestController
@RequestMapping("/comment")
public class ForumCommentController {
  @Resource ForumCommentDao commentDao;

  @GetMapping("/detail/{id}")
  public ForumResult getCommentByDetail(@PathVariable(name = "id") Integer detailId) {
    return ForumResultUtils.ok(commentDao.detailCommentList(detailId));
  }

  @PostMapping("/reply")
  public ForumResult reply(@RequestBody @Valid ForumDetailCommentDTO dto) {
    return ForumResultUtils.ok(commentDao.commentDetail(dto));
  }
}
